package com.cn.user.controller;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.cn.user.entity.MyUser;
import com.cn.user.service.UserService;
import com.github.pagehelper.PageHelper;

//@RestController注解相当于@ResponseBody ＋ @Controller合在一起的作用。
@Controller
@RequestMapping("homepage")
public class MyUserController {
	
	@Resource
	private UserService userService;

	@RequestMapping("selectUsers")
	@ResponseBody
	public List<MyUser> selectUsers(Integer pageNum) {
		if(pageNum==null||pageNum==null){
			pageNum = 1;
		}
		PageHelper.startPage(pageNum,3);  //显示第一页2条数据
		MyUser myUser = new MyUser();
		List<MyUser> selectUser = userService.selectUser(myUser);
		return selectUser;
	}
	@RequestMapping("index")
	public String index(Model model,String name) {
		model.addAttribute("name", name);
		return "index/index";
	}
	@RequestMapping("live")
	public String live() {
		return "index/live";
	}
	
	
}
